import request from '@/utils/request'

// 查询待办任务列表
export function todoList(query) {
  return request({
    url: '/flowable/task/todoList',
    method: 'get',
    params: query
  })
}

// 查询待办任务数量
export function todoCount(query) {
  return request({
    url: '/flowable/task/todoCountByCategory',
    method: 'get',
    params: query
  })
}

// 根据流程实例查询当前人的taskId 
export function taskIdByProcId(procId) {
  return request({
    url: '/flowable/task/taskIdByProcId/' + procId,
    method: 'get',
  })
}

// 保存数据
export function saveData(data) {
  return request({
    url: '/flowable/task/saveData',
    method: 'post',
    data: data
  })
}

// 完成任务
export function complete(data) {
  return request({
    url: '/flowable/task/complete',
    method: 'post',
    data: data
  })
}

// 委派任务
export function delegate(data) {
  return request({
    url: '/flowable/task/delegate',
    method: 'post',
    data: data
  })
}

// 退回任务
export function returnTask(data) {
  return request({
    url: '/flowable/task/return',
    method: 'post',
    data: data
  })
}

// 驳回任务
export function rejectTask(data) {
  return request({
    url: '/flowable/task/reject',
    method: 'post',
    data: data
  })
}

// 可退回任务列表
export function returnList(data) {
  return request({
    url: '/flowable/task/returnList',
    method: 'post',
    data: data
  })
}

// 下一节点
export function getNextFlowNode(data) {
  return request({
    url: '/flowable/task/nextFlowNode',
    method: 'post',
    data: data
  })
}

// 部署流程实例
export function deployStart(deployId) {
  return request({
    url: '/flowable/process/startFlow/' + deployId,
    method: 'get',
  })
}

// 查询流程定义详细
export function getDeployment(id) {
  return request({
    url: '/system/deployment/' + id,
    method: 'get'
  })
}

// 新增流程定义
export function addDeployment(data) {
  return request({
    url: '/system/deployment',
    method: 'post',
    data: data
  })
}

// 修改流程定义
export function updateDeployment(data) {
  return request({
    url: '/system/deployment',
    method: 'put',
    data: data
  })
}

// 删除流程定义
export function delDeployment(id) {
  return request({
    url: '/system/deployment/delete/' + id,
    method: 'delete'
  })
}

// 导出流程定义
export function exportDeployment(query) {
  return request({
    url: '/system/deployment/export',
    method: 'get',
    params: query
  })
}

// 转办
export function assignTask(data) {
  return request({
    url: '/flowable/task/assign',
    method: 'post',
    data: data
  })
}

// 委派
export function delegateTask(data) {
  return request({
    url: '/flowable/task/delegate',
    method: 'post',
    data: data
  })
}

// 合同评审等  btnList
export function listBusBtn(query) {
  return request({
    url: '/flowable/deployBtn/btn/list',
    method: 'get',
    params: query
  })
}

// 合同评审等  btnList
export function listBusBtnList(query) {
  return request({
    url: '/flowable/deployBtn/list',
    method: 'get',
    params: query
  })
}

//查询流程定义信息
export function getProcessDefinition(taskId) {
  return request({
    url: '/flowable/task/processDefinition/' + taskId,
    method: 'get',
  })
}
